home *** CD-ROM | disk | FTP | other *** search
- Path: news.mindlink.net!news
- From: genew@mindlink.bc.ca (Gene Wirchenko)
- Newsgroups: comp.lang.c
- Subject: Re: What does the -O option do???!!!
- Date: Sun, 11 Feb 1996 21:30:34 GMT
- Organization: MIND LINK! - British Columbia, Canada
- Message-ID: <4flna0$qe@fountain.mindlink.net>
- References: <4ehger$cj9@mark.ucdavis.edu> <823827008snz@genesis.demon.co.uk> <4fiphrINNrvr@keats.ugrad.cs.ubc.ca> <9602102332.AA09466@dxmint.cern.ch> <4flhrhINNtj@keats.ugrad.cs.ubc.ca>
- NNTP-Posting-Host: line202.nwm.mindlink.net
- X-Newsreader: Forte Free Agent 1.0.82
-
- c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) wrote:
-
- >In article <9602102332.AA09466@dxmint.cern.ch>,
- >Dan Pop <danpop@mail.cern.ch> wrote:
- >>c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) writes:
- >>
- >>>... as long as it is not hard-coded to treat identifiers like "free" specially.
- >>
- >>A compiler is free to treat identifiers like "free" specially after the
- >>relevant header has been included.
- >>
- >>>If you write your own free() with different semantics, you would not want the
- >>>compiler messing with that.
- >>
- >>If you write your own free() you invoke undefined behaviour and you can't
- >>expect the compiler to behave in a sensible way. The implementation
- >>namespace is a big taboo in C.
-
- >Are you serious? What if I'm writing a little embedded kernel that doesn't use
- >anything resembling the standard C library, and I use free() for something
- >quite different?
-
- If a compiler had that sort of optimization, I can easily imagine
- a switch for turning it off:
- cc thingie.c -nostdlibuse
- or
- #pragma nostdlibuse
-
- >This is truly silly. The standard may say one thing, but it's despicable to
- >actually implement a compiler that treats free() specially. There is nothing in
- >the semantics of free() that requires special treatment in order to do its job.
-
- This is truly silly. Of course, there could be. It is
- implementation defined as to what it would be. It might happen if you
- "...use free() for something quite different...".
-
- >For one thing, malloc() is far from a perfect allocation scheme, so why give it
- >preferential treatment? I might design my own library which uses allocation
- >handles, and performs heap compaction, for instance.
-
- Alright, alright, so you're you're brilliant and your new memory
- allocation scheme makes you worthy of the Nobel Prize!
- Question: are you really going to call it malloc()?
-
- >>>It's just another function, after all.
- >>
- >>No, it isn't. Have a look at the standard.
-
- >I just had a look at the sources for my standard library. It sure looks like a
- >function to me. (Walks like a duck, quacks like a duck, ... )
-
- It is. It is a Standard defined function. Now, take another
- look at the sources for your standard library. See any of your app
- code in there? If not, why do you suppose that would be?
-
- >I wonder whether the seats of that ANSI commitee were actually populated by
- >programmers.
- >--
-
- Sure, but they obviously weren't of your religious beliefs, so
- flame 'em all! <G>
-
- Sincerely,
-
- Gene Wirchenko
-
- C Pronunciation Guide:
- y=x++; "wye equals ex plus plus semicolon"
- x=x++; "ex equals ex doublecross semicolon"
-
-